package com.longtop.leaning.ui;

import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

import com.longtop.leaning.data.UIData;

public class FunctionList extends List implements CommandListener{
	private static final String[] stringArray = { "航班查询", "数据下载" };
	
	public FunctionList() {
		super("选择功能", Choice.IMPLICIT, stringArray, null);
		super.addCommand(UIData.CMD_BACK);
		super.addCommand(UIData.CMD_OK);
		super.setCommandListener(this);
	}

	public void commandAction(Command c, Displayable d) {
		if(c == UIData.CMD_OK || c == List.SELECT_COMMAND){
			switch(((List) d).getSelectedIndex()){
				case 0://航班查询
					UIData.display.setCurrent(new MainForm());
					break;
				case 1://数据下载
					UIData.display.setCurrent(new DownloadForm());
					break;
			}
		}
		if (c == UIData.CMD_BACK) {
			UIData.display.setCurrent(new LoginForm());
		}
		
	}

}
